package ca.newcommerce.youtube.data
{
    import ca.newcommerce.youtube.iterators.*;

    public class SubscriptionData extends AbstractData
    {
        protected var _data:Object;
        public static const FAVORITE_SUBSCRIPTION:String = "favorite";
        public static const QUERY_SUBSCRIPTION:String = "query";
        public static const CHANNEL_SUBSCRIPTION:String = "channel";
        public static const UNKNOWN_SUBSCRIPTION:String = "unknown";

        public function SubscriptionData(param1:Object)
        {
            this._data = param1;
            return;
        }// end function

        public function get links() : LinkIterator
        {
            return new LinkIterator(this._data.link);
        }// end function

        public function get updated() : String
        {
            return fromObj(this._data, "updated");
        }// end function

        public function get authors() : AuthorIterator
        {
            return new AuthorIterator(this._data.author);
        }// end function

        public function get published() : String
        {
            return fromObj(this._data, "published");
        }// end function

        public function get username() : String
        {
            return fromObj(this._data, "yt$username");
        }// end function

        public function get title() : String
        {
            return fromObj(this._data, "title");
        }// end function

        public function get queryString() : String
        {
            return fromObj(this._data, "yt$queryString");
        }// end function

        public function get type() : String
        {
            var _loc_1:CategoryIterator = null;
            var _loc_2:CategoryData = null;
            do
            {
                
                if (_loc_2.scheme == "subscriptiontypes")
                {
                    if (_loc_2.term == FAVORITE_SUBSCRIPTION)
                    {
                        return FAVORITE_SUBSCRIPTION;
                    }
                    if (_loc_2.term == CHANNEL_SUBSCRIPTION)
                    {
                        return CHANNEL_SUBSCRIPTION;
                    }
                    if (_loc_2.term == QUERY_SUBSCRIPTION)
                    {
                        return QUERY_SUBSCRIPTION;
                    }
                }
                var _loc_3:* = _loc_1.next();
                _loc_2 = _loc_1.next();
            }while (_loc_3)
            return UNKNOWN_SUBSCRIPTION;
        }// end function

        public function get id() : String
        {
            return fromObj(this._data, "id");
        }// end function

        public function get categories() : CategoryIterator
        {
            return new CategoryIterator(this._data.category);
        }// end function

        public function get feedLink() : FeedLinkData
        {
            return new FeedLinkData(this._data.gd$feedLink);
        }// end function

    }
}
